package cn.tedu.micro.demo.all.controller;

import cn.tedu.micro.demo.all.service.OrderService;
import cn.tedu.micro.demo.common.protocol.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class OrderController {
    @Autowired
    private OrderService orderService;
    //订单提交
    @PostMapping("/order/submit")
    public JsonResult<Boolean> subimitOrder(
            Integer userId,
            String productCode,
            Integer count){
        Boolean result=orderService.submitOrder(userId,productCode,count);
        if(result){
            //新增成功
            return JsonResult.ok("下单成功",result);
        }else{
            return JsonResult.ok("下单失败",result);
        }
    }
}
